<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象的属性</title>
</head>
<body>
    <script>
        person = {
            name:"cq",
            age:20
        }
       
        // //数据描述属性
        // Object.defineProperty(person,"name",{
        //     configurable:false,
        //     writable:false,
        //     enumerable:false,
        //     value:"cqcq"
        // })

        //存取属性
        var _name = "";
        Object.defineProperty(person,"name",{
            configurable:false,
            set:function(value)
            {
              _name = value;
              console.log("我被修改了");
            },
            get:function()
            {
              console.log("我被获取了");
              return _name;
            }
        })
        person.name = "cqcq";
        console.log(person.name);

       console.log(  Object.getOwnPropertyDescriptor(person,"name"));
    </script>
</body>
</html>